//
//  NSLockDemo.m
//  JKThreadTest
//
//  Created by 王冲 on 2018/10/25.
//  Copyright © 2018年 JK科技有限公司. All rights reserved.
//

#import "NSLockDemo.h"

@interface NSLockDemo ()

@property(nonatomic,strong) NSLock *tickeLock;
@property(nonatomic,strong) NSLock *moneyLock;

@end

@implementation NSLockDemo


-(instancetype)init{
    
    if (self = [super init]) {
        
        // 初始化锁
        // 买票的锁
        self.tickeLock = [[NSLock alloc]init];
        self.moneyLock = [[NSLock alloc]init];
    }
    
    return self;
}

-(void)__buyTicket{
    
    // 加锁
    [self.tickeLock lock];
    
    [super __buyTicket];
    
    // 解锁
   [self.tickeLock unlock];
    
}

-(void)__drawMoney{
    
    [self.moneyLock lock];
    
    [super __drawMoney];
    
    [self.moneyLock unlock];
}

-(void)__saveMoney{
    
    [self.moneyLock lock];
    
    [super __saveMoney];
    
    [self.moneyLock unlock];
}

@end
